//
//  WKWebViewController.m
//  SHShopping
//
//  Created by 坤鼎 on 2019/8/27.
//  Copyright © 2019 kunding. All rights reserved.
//

#import "WKWebViewController.h"

@interface WKWebViewController ()

@end

@implementation WKWebViewController

- (instancetype)init {
    if (self = [super init]) {
        //允许侧滑返回
        self.allowsBFNavigationGesture = YES;
        //进度条颜色
        self.progressTintColor = [UIColor blackColor];
        //拦截每次请求的url
        self.needInterceptRequest = YES;
        //优先从本地拿数据，且忽略请求生命时长和过期时间。但是如果没有本地cache，则请求源数据
        self.cachePolicy = NSURLRequestReturnCacheDataElseLoad;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)interceptRequestWithNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
//    NSLog(@"当前加载的url:%@", navigationAction.request.URL);
    decisionHandler(WKNavigationActionPolicyAllow);
}

@end
